package com.xbongbong.saas.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.paas.enums.FieldTypeEnum;
import com.xbongbong.paas.enums.ScreenTypeEnum;
import lombok.Getter;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * 在线支付流水枚举
 * @author zcp
 * @version v1.0
 * @since v1.0
 */
@Getter
public enum OnlinePaymentFlowDistributorEnum {

    //基础信息
    BASE_INFO("other_1", "enum.onlinePaymentFlow.attrName.base_info", "baseInfo", FieldTypeEnum.SEPARATOR.getType(), SetTypeEnum.DISABLE_REPEAT.getCode(), 1, 0, ShowTypeEnum.EDIT_DETAIL.getCode(), 10000, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),

    //------不展示到页面的字段
    /**
     * 公众号id或支付宝分配给开发者的应用ID等
     */
    ONLINE_APP_ID("text_1", "enum.onlinePaymentFlow.attrName.online_app_id", "onlineAppId", FieldTypeEnum.COMBO.getType(), 3, 1, 0, ShowTypeEnum.NONE.getCode(), 9990, 0, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    /**
     * 直连商户的商户号或商户代码
     */
    MCHID("text_2", "enum.onlinePaymentFlow.attrName.mchid", "mchid", FieldTypeEnum.COMBO.getType(), 3, 1, 0, ShowTypeEnum.NONE.getCode(), 9980, 0, 0, ScreenTypeEnum.SCREEN_OFF.getType()),

    //------展示到页面的字段
    /**
     * 支付流水号,这边就是商户订单号，我们这边按照某种规则去生成
     * 微信：wx+年月日+时分秒
     * 支付宝:ali+年月日+时分秒
     * 银联:union+年月日+时分秒
     */
    SERIAL_NO("serialNo", "enum.onlinePaymentFlow.attrName.serial_no", "sheetNo", FieldTypeEnum.SERIALNO.getType(), 1, 0, 0, ShowTypeEnum.ALL.getCode(), 9970, 1, 1, ScreenTypeEnum.SCREEN_GROUP.getType()),
    /**
     * 支付方式，根据支付方式查找对应资金设置内的支付配置
     * @see com.xbongbong.pro.enums.fund.enums.PayMethodFundSetEnum
     */
    PAY_METHOD("text_3", "enum.onlinePaymentFlow.attrName.pay_method", "payMethod", FieldTypeEnum.COMBO.getType(), 3, 1, 0, ShowTypeEnum.ALL.getCode(), 9960, 1, 0, ScreenTypeEnum.SCREEN_GROUP.getType()),
    /**
     * 交易金额
     */
    AMOUNT("num_1", "enum.onlinePaymentFlow.attrName.amount", "amount", FieldTypeEnum.NUM.getType(), 1, 0, 0, ShowTypeEnum.ALL.getCode(), 9950, 1, 1, ScreenTypeEnum.SCREEN_GROUP.getType()),
    /**
     * 在线支付费率
     */
    FEE_RATE("num_2","enum.onlinePaymentFlow.attrName.fee_rate", "feeRate", FieldTypeEnum.NUM.getType(), SetTypeEnum.DISABLE_OPEN.getCode(), 0, 0, ShowTypeEnum.ALL.getCode(), 9940, 1, 0, ScreenTypeEnum.SCREEN_GROUP.getType()),
    /**
     * 实际到账金额
     */
    AMOUNT_ACTUAL("num_3", "enum.onlinePaymentFlow.attrName.amount_actual", "amountActual", FieldTypeEnum.NUM.getType(), 1, 0, 0, ShowTypeEnum.ALL.getCode(), 9930, 1, 0, ScreenTypeEnum.SCREEN_GROUP.getType()),
    /**
     * 经销商id
     */
    DISTRIBUTOR_ID("text_4", "enum.onlinePaymentFlow.attrName.distributor_id", "distributorId", FieldTypeEnum.LINK_BUSINESS_SINGLE.getType(), 1, 0, 0, ShowTypeEnum.ALL.getCode(), 9920, 0, 0, ScreenTypeEnum.SCREEN_GROUP.getType()),

    /**
     * 付款方名称
     */
    PAYER_ID_LINK_TEXT("text_12", "enum.onlinePaymentFlow.attrName.payer_id_link_text", "payerIdLinkText", FieldTypeEnum.TEXT.getType(), 1, 0, 0, ShowTypeEnum.ALL.getCode(), 9915, 1, 1, ScreenTypeEnum.SCREEN_OFF.getType()),

    /**
     * 类型：1订单支付；2支付货款；3预收款充值(经销商端叫做预付款充值)；4订单退款
     * @see com.xbongbong.pro.enums.fund.enums.OnlinePaymentFlowTypeEnum
     */
    TYPE("text_6", "enum.onlinePaymentFlow.attrName.type", "type", FieldTypeEnum.COMBO.getType(), 1, 0, 0, ShowTypeEnum.ALL.getCode(), 9910, 1, 1, ScreenTypeEnum.SCREEN_GROUP.getType()),
    /**
     * 状态：完成、失败
     * @see com.xbongbong.pro.enums.fund.enums.OnlinePaymentFlowStatusEnum
     */
    STATUS("text_7", "enum.onlinePaymentFlow.attrName.status", "status", FieldTypeEnum.COMBO.getType(), 1, 0, 0, ShowTypeEnum.ALL.getCode(), 9900, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    /**
     * 订货单编号 - 即合同
     */
    ORDER_ID("text_8", "enum.onlinePaymentFlow.attrName.order_id", "orderId", FieldTypeEnum.LINK_BUSINESS_MULTI.getType(), 1, 0, 0, ShowTypeEnum.DETAIL.getCode(), 9890, 1, 1, ScreenTypeEnum.SCREEN_SEARCH.getType()),
    /**
     * 回款单编号
     */
    SHEET_ID("text_10", "enum.onlinePaymentFlow.attrName.sheet_id", "sheetId", FieldTypeEnum.LINK_BUSINESS_MULTI.getType(), 1, 0, 0, ShowTypeEnum.ALL.getCode(), 9880, 1, 0, ScreenTypeEnum.SCREEN_SEARCH.getType()),
    /**
     * 支付时间
     */
    PAY_TIME("date_1", "enum.onlinePaymentFlow.attrName.pay_time", "payTime", FieldTypeEnum.DATETIME.getType(), 1, 0, 0, ShowTypeEnum.ALL.getCode(), 9870, 1, 1, ScreenTypeEnum.SCREEN_GROUP.getType()),

    /**
     * 支付人相关信息，如微信账号、支付宝账号等
     */
    PAYER("array_1", "enum.onlinePaymentFlow.attrName.payer", "payer", FieldTypeEnum.USER_GROUP.getType(), 1, 0, 0, ShowTypeEnum.NONE.getCode(), 9850, 0, 0, ScreenTypeEnum.SCREEN_OFF.getType()),

    CREATOR_ID("creatorId", "enum.onlinePaymentFlow.attrName.creator_id", "creatorId", FieldTypeEnum.CREATORID.getType(), 1, 0, 0, ShowTypeEnum.ALL.getCode(), 9820, 1, 0, ScreenTypeEnum.SCREEN_GROUP.getType()),
    ADD_TIME("addTime", "enum.onlinePaymentFlow.attrName.add_time", "addTime", FieldTypeEnum.ADDTIME.getType(), 1, 1, 0, ShowTypeEnum.ALL.getCode(), 9810, 1, 0, ScreenTypeEnum.SCREEN_GROUP.getType()),
    UPDATE_TIME("updateTime", "enum.onlinePaymentFlow.attrName.update_time", "updateTime", FieldTypeEnum.UPDATETIME.getType(), 1, 1, 0, ShowTypeEnum.ALL.getCode(), 9800, 1, 0, ScreenTypeEnum.SCREEN_GROUP.getType()),

    /**
     * 关联经销商 名称
     */
    DISTRIBUTOR_ID_LINK_TEXT("text_5","enum.onlinePaymentFlow.attrName.distributor_id_link_text","distributorIdLinkText",FieldTypeEnum.TEXT.getType(),SetTypeEnum.DISABLE_ALL.getCode(),0,1,ShowTypeEnum.NONE.getCode(),9780,1,1,ScreenTypeEnum.SCREEN_OFF.getType()),
    /**
     *关联订货单编号
     */
    ORDER_ID_LINK_TEXT("text_9","enum.onlinePaymentFlow.attrName.order_id_link_text","orderIdLinkText",FieldTypeEnum.TEXT.getType(),SetTypeEnum.DISABLE_ALL.getCode(),0,1,ShowTypeEnum.NONE.getCode(),9770,1,1,ScreenTypeEnum.SCREEN_OFF.getType()),
    /**
     * 关联回款单编号
     */
    SHEET_ID_LINK_TEXT("text_11","enum.onlinePaymentFlow.attrName.sheet_id_link_text","sheetIdLinkText",FieldTypeEnum.TEXT.getType(),SetTypeEnum.DISABLE_ALL.getCode(),0,1,ShowTypeEnum.NONE.getCode(),9760,1,1,ScreenTypeEnum.SCREEN_OFF.getType()),

    /**
     * 付款方 - 经销商下的用户
     */
    PAYER_ID("long_1", "enum.onlinePaymentFlow.attrName.payer_id", "payerId", FieldTypeEnum.LONG.getType(), 1, 0, 0, ShowTypeEnum.NONE.getCode(), 9750, 1, 1, ScreenTypeEnum.SCREEN_SEARCH.getType()),

    /**
     * 支付流水中隐藏待付款信息，这个字段存json字符串，主要是为了以后通过在线支付流水去生成回款单
     */
    PAYMENT_AMOUNT_DETAIL("text_13", "enum.onlinePaymentFlow.attrName.payment_amount_detail", "paymentAmountDetail", FieldTypeEnum.TEXTAREA.getType(), 1, 0, 0, ShowTypeEnum.NONE.getCode(), 9740, 1, 1, ScreenTypeEnum.SCREEN_OFF.getType()),

    /**
     * 待付款id,主要是后续生成回款单的时候会用到
     */
    PAYMENT_ID("text_14", "enum.onlinePaymentFlow.attrName.payment_id", "paymentId", FieldTypeEnum.TEXT.getType(), 1, 0, 0, ShowTypeEnum.NONE.getCode(), 9730, 1, 1, ScreenTypeEnum.SCREEN_OFF.getType()),

    /**
     * 微信支付订单号（后面可能是支付宝或者银联的订单号）
     */
    TRANSACTION_ID("text_15", "enum.onlinePaymentFlow.attrName.transaction_id", "transactionId", FieldTypeEnum.TEXT.getType(), 1, 0, 0, ShowTypeEnum.NONE.getCode(), 9720, 1, 1, ScreenTypeEnum.SCREEN_OFF.getType()),

    /**
     * 支付来源，后面生成回款单的时候会用到, 1:订单过来的 2:预付款充值 3:待付款
     */
    PAY_SOURCE("text_16", "enum.onlinePaymentFlow.attrName.pay_source", "paySource", FieldTypeEnum.TEXT.getType(), 1, 0, 0, ShowTypeEnum.NONE.getCode(), 9710, 1, 1, ScreenTypeEnum.SCREEN_OFF.getType()),

    /**
     * 这笔单子是否发生退款 1:代表否 2:代表是 默认是否
     */
    IS_REFUND("text_17", "enum.onlinePaymentFlow.attrName.is_refund", "isRefund", FieldTypeEnum.TEXT.getType(), 1, 0, 0, ShowTypeEnum.NONE.getCode(), 9700, 1, 1, ScreenTypeEnum.SCREEN_OFF.getType()),

    /**
     * 支付状态  com.xbongbong.distributor.enums.DistributorPayStatusEnum
     */
    PAY_STATUS("text_18", "enum.onlinePaymentFlow.attrName.pay_status", "payStatus", FieldTypeEnum.TEXT.getType(), 1, 0, 0, ShowTypeEnum.NONE.getCode(), 9690, 1, 1, ScreenTypeEnum.SCREEN_OFF.getType()),
    ;
    /**
     * 英文名称
     */
    private String attr;
    /**
     * 中文名称
     */
    private String attrName;
    /**
     * 对应saas中的attr
     */
    private String saasAttr;
    /**
     * 字段类型，详见
     *
     * @see FieldTypeEnum
     */
    private Integer fieldType;
    /**
     * 重命名、判重、启用必填等权限
     * 1.重命名+字段权限
     * 2.重命名+字段权限+查重
     * 3.重命名+字段权限+启用、必填
     * 4.重命名+字段权限+查重+启用、必填
     * 注：pro中启用和必填是同一个权限，同时启用或同时关闭
     */
    private Integer setType;
    /**
     * 模板设计阶段字段是否允许编辑
     * 1：允许编辑
     * 0：不允许编辑
     */
    private Integer designEditable;
    /**
     * 字段是否显示在模板设计界面
     * 1：不显示
     * 0：显示
     */
    private Integer editHide;
    /**
     * 字段在各个界面（新建、编辑、列表、详情）的展现形式
     * 详见
     *
     * @see ShowTypeEnum
     */
    private Integer showType;
    /**
     * 字段在模板设计界面的排序
     * 建议不要用连续的数字，可以用等差数列，以防以后在两个字段之间加入新字段
     */
    private Integer sort;
    /**
     * 字段在各个界面是否可见(启用)
     * 1：可见
     * 0：不可见
     * 注：字段在具体页面的可见性需要用属性和showType联合判断，在visible=1的情况下判断showType
     */
    private Integer visible;
    /**
     * 字段是否必填
     * 1：必填
     * 0：不必填
     */
    private Integer required;
    /**
     * 筛选类型
     * 1：可筛选
     * 2：不可筛选
     */
    private Integer screenType;

    OnlinePaymentFlowDistributorEnum(String attr, String attrName, String saasAttr, Integer fieldType, Integer setType, Integer designEditable,
                                     Integer editHide, Integer showType, Integer sort, Integer visible, Integer required, Integer screenType) {
        this.attr = attr;
        this.attrName = attrName;
        this.saasAttr = saasAttr;
        this.fieldType = fieldType;
        this.setType = setType;
        this.designEditable = designEditable;
        this.editHide = editHide;
        this.showType = showType;
        this.sort = sort;
        this.visible = visible;
        this.required = required;
        this.screenType = screenType;
    }
    /**
     * app端默认标题显示字段
     *
     * @return java.util.List<java.lang.Object>
     * @author 徐俊杰
     * @date 2019/11/20 15:22
     * @since v1.0
     */
    public static List<Object> getTitleAttrList() {
        return Collections.singletonList(SERIAL_NO);
    }

    /**
     * app端默认摘要
     *
     * @return java.util.List<java.lang.Object>
     * @author 徐俊杰
     * @date 2019/11/20 15:24
     * @since v1.0
     */
    public static List<Object> getSummaryAttrList() {
        return Arrays.asList(PAYER_ID_LINK_TEXT, PAY_TIME);
    }

    public String getAttrName() {
        return I18nMessageUtil.getMessage(attrName);
    }

    public String getI18nAttrName() {
        return attrName;
    }

    public static String getI18nValue(String value) {
        return I18nMessageUtil.getMessage(value);
    }
}
